#!/bin/bash
set -e

echo $PATH

mkdir -p /data/mongo/shard2/shard2-4701{1,3,5,7}
mkdir -p /data/mongo/shard2/logs

mongod -f shard2/shard2-47011.conf
mongod -f shard2/shard2-47013.conf
mongod -f shard2/shard2-47015.conf
mongod -f shard2/shard2-47017.conf


mongo --port 47011 << EOF
use admin 
var cfg ={"_id":"shard2", 
"protocolVersion": 1,
"members":[ 
    {"_id":1,"host":"172.17.0.4:47011"}, 
    {"_id":2,"host":"172.17.0.4:47013"}, 
    {"_id":3,"host":"172.17.0.4:47015"},
    {"_id":4,"host":"172.17.0.4:47017","arbiterOnly":true}] 
};
rs.initiate(cfg)
rs.status()
EOF
